﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CCWin;

namespace DC.Views
{
    public partial class Form_ProjectFilter : Skin_DevExpress
    {
        public string searchText = string.Empty;
        public string ProjectID = string.Empty;

        public Form_ProjectFilter()
        {
            InitializeComponent();
        }

        Utils.Database DB = Utils.Global.GlobalDB;

        private void Form_ProjectFilter_Load(object sender, EventArgs e)
        {
            string sql = @"select Project_ID as 序号,Project_Name as 名称,cast(Project_Price as decimal(10,2)) as 单价
                            from Project where Project_Abbreviation like '%" + searchText + "%' or Project_Name like '%" + searchText + "%'";
            skinDataGridView1.DataSource = DB.GetDs(sql).Tables[0].DefaultView;
            skinDataGridView1.Columns[1].Width = 200;
        }

        private void skinDataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ProjectID = skinDataGridView1.CurrentRow.Cells[0].Value.ToString();
                this.Close();
            }
        }
    }
}
